(function(angular) {
	'use strict';
	angular.module('fs.waf').controller('cda.lookup.acctMoreDataViewController', acctMoreDataViewController);
	acctMoreDataViewController.$inject = [ '$scope', '$q', '$uibModalInstance', 'Constants', 'dialogsModule', 'gridService', 'modalService', 'layoutConfig', 'validatorConfig', 'authService' ];
	function acctMoreDataViewController($scope, $q, $uibModalInstance, Constants, dialogsModule, gridService, modalService, layoutConfig, validatorConfig, authService) {
		var ctrl = this, log = $scope.loggerFactory.getLogger("acctMoreDataViewLookup");
		ctrl.dialogsModule = dialogsModule;
		ctrl.config = layoutConfig;
		ctrl.validatorConfig = validatorConfig;
		
		ctrl.close = function() {
			if (!dialogsModule.btnCallback || !dialogsModule.btnCallback['close'] || dialogsModule.btnCallback['close']() !== false) {
				$uibModalInstance.dismiss();
			}
		};
		
		ctrl.init = function() {
			ctrl.selectedProperties = gridService.createInnerGridOptions($scope, ctrl.config.tableConfigs.table1, rowSelectionChanged1);
			ctrl.selectedProperties.data = 'vm.account.selectedProperties';
			ctrl.selectedProperties.enableRowHeaderSelection = false;
			ctrl.selectedProperties.enableSelectAll = false;
			ctrl.account = {};
			ctrl.search();
		};
		
		ctrl.search = function() {
			if(ctrl.dialogsModule.params && ctrl.dialogsModule.params.moreData){
				ctrl.account.moreData = ctrl.dialogsModule.params.moreData;
			}
			authService.search(ctrl.account).then(function(response) {
				angular.merge(ctrl.account, response.data);
				gridService.updateGridOptions(ctrl.account, ctrl.availableProperties);
			}, angular.noop);
		};

		function rowSelectionChanged1(eventRow, selectedRows) {
			ctrl.selectedRows1 = selectedRows;
		}
	}
})(angular);
